import 'dart:async';

void main() {
  var data = [1, 2, 3, 4, 5];
  var stream = new Stream.fromIterable(data);

  // define a stream transformer (hanldeData 参数必须添加类型，否则报错)
  var transformer = new StreamTransformer.fromHandlers(
      handleData: (int value, EventSink sink) {
    sink.add("Message: $value");
    sink.add("Body: $value");
  });

// transform the stream and listen to its output
  stream.transform(transformer).listen((value) => print("listen: $value"));
  // equivalent below
  //ctrl.stream.map((e) => e * 2).listen(print);
}

//EOP
